package com.yh.rbac.Interceptors;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.yh.rbac.entity.User;
import com.yh.rbac.tools.Constant;

public class SystemSessionInterceptor extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		User user  = (User) request.getSession().getAttribute(Constant.LOGIN_USER) ;
		if (user == null) {
			response.sendRedirect(request.getContextPath() + "/user/login.shtml");
			return false ;
		}
		return true;
	}
	
}
